package com.itheima.dao.impl;

import com.itheima.dao.LogDao;
import com.itheima.domain.Student;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;

public class LogDaoImpl implements LogDao {
    @Override
    public Student LogDaoStudent(Student student) throws IOException {
        Student stu=new Student();
        stu.setName(student.getName());
        stu.setPassword(student.getPassword());
        SqlSession sqlSession = new SqlSessionFactoryBuilder().build(Resources.getResourceAsStream("mybatis-config.xml")).openSession();
        Student o = (Student) sqlSession.selectOne("UserMapper.selectbyid", stu);
        return o;
    }

    /*public static void main(String[] args) throws Exception {
        Student s=new Student();
        s.setName("严朝阳");
        s.setPassword("123");
        Student student = new LogDaoImpl().LogDaoStudent(s);
        System.out.println(student);

    }*/
}
